home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / VISUALBA / BOZOL2.ZIP / BOZO_IO.BAS next >
BASIC Source File  |  1994-02-08  |  6KB  |  225 lines

  1. $IF %IO.DIRECT ' The following IO subroutines are for direct hardware access
  2.  
  3. SUB BOZOPRINT (X$)
  4.         PRINT X$;
  5. END SUB
  6.  
  7.  
  8. FUNCTION BOZOINPUT$
  9.         LINE INPUT X$
  10.         BOZOINPUT$=X$
  11. END FUNCTION
  12.  
  13.  
  14. FUNCTION BOZOINKEY$
  15.         BOZOINKEY$=INKEY$
  16. END FUNCTION
  17.  
  18.  
  19. SUB BOZOCLS
  20.     CLS
  21. END SUB
  22.  
  23.  
  24. SUB BOZOLOCATE(Row%, Col%)
  25.     LOCATE Row%, Col%
  26. END SUB
  27.  
  28.  
  29. SUB BOZOCOLOR (Fg%, Bg%)
  30.     COLOR Fg%, Bg%
  31. END SUB
  32.  
  33. FUNCTION BOZOCSRLIN
  34.     BOZOCSRLIN=CSRLIN
  35. END FUNCTION
  36.  
  37. FUNCTION BOZOPOS
  38.     BOZOPOS=POS(0)
  39. END FUNCTION
  40.  
  41.  
  42. $ENDIF
  43.  
  44. $IF %IO.BIOS
  45.  
  46. SUB BOZOLOCATE (Row%, Col%)
  47.         REG 1, &H0200  ' AH contains function 2 = set cursor position
  48.         REG 2, 0       ' BX contains text page 0
  49.         REG 4, ((Row%+1) * 256) + (Col%+1)  ' DX contains coordinates
  50.         CALL INTERRUPT &H10 ' call BIOS
  51. END SUB
  52.  
  53. SUB BOZOCOLOR (Fg%, Bg%)
  54.         SHARED Attribute%
  55.         Attribute% = (Bg% * 16) + Fg%
  56. END SUB
  57.  
  58. SUB BOZOPRINT (X$)
  59.         SHARED Attribute%
  60.         IF Attribute%=0 THEN Attribute%=&H07
  61.         FOR Character% = 1 TO LEN(X$)
  62.                 C$=MID$(X$,Character%, 1)
  63.                 IF C$=CHR$(13) THEN
  64.                     CR
  65.                 ELSE
  66.                 REG 2, Attribute%  ' set color for next write
  67.                 REG 3, 1           ' set repeat rate per char to 1
  68.                     REG 1, &H0900 + ASCII(C$)
  69.                     CALL INTERRUPT &H10
  70.                     CALL BIOS.ADVANCE.CURSOR
  71.                 END IF
  72.         NEXT Character%
  73. END SUB
  74.  
  75. FUNCTION BOZOINPUT$ (Prompt$)
  76. IF LEN(Prompt$) THEN BIOSPRINT Prompt$
  77.         I$=""
  78.         DO
  79.                 K$=BOZOINKEY$
  80.                 IF K$=CHR$(13) THEN EXIT DO
  81.                 IF LEN(K$)=1 THEN I$=I$+K$:BOZOPRINT K$
  82.                 ' add possible hot key checks here
  83.         LOOP
  84.         CR      ' carriage return
  85. BOZOINPUT$=I$
  86. END
  87.  
  88. FUNCTION BOZOINKEY$
  89.         REG 1, 0 ' AX = keyboard BIOS function 0, read character
  90.         CALL INTERRUPT &H16 ' call keyboard BIOS
  91.         AL%=(REG(1) AND &HFF)
  92.         IF AL%=0 THEN BOZOINKEY$="" ELSE BOZOINKEY$=CHR$(AL%)
  93. END FUNCTION
  94.  
  95. SUB BIOS.ADVANCE.CURSOR
  96. SHARED Attribute%
  97.     ' get cursor position
  98.         REG 1, &H0300
  99.         REG 2, 0
  100.         CALL INTERRUPT &H10
  101.         Row% = REG(4) \ 256
  102.         Col% = (REG(4) AND &HFF)
  103.  
  104.  
  105.         ' establish new cursor position and scroll if necessary
  106.         INCR Col%
  107.         IF Col%=80 THEN
  108.             Col%=0
  109.                 INCR Row%
  110.                 IF Row%=24 THEN
  111.                     Row%=23
  112.                         ' Scroll window up
  113.                         REG 1, &H0601
  114.                         REG 2, Attribute%
  115.                         REG 3, 0
  116.                         REG 4, (23 * 256) + 79
  117.                         CALL INTERRUPT &H10
  118.                 END IF
  119.         END IF
  120.  
  121.         ' locate new cursor position
  122.  
  123.         REG 1, &H0200  ' AH contains function 2 = set cursor position
  124.         REG 2, 0       ' BX contains text page 0
  125.         REG 4, (Row% * 256) + Col%  ' DX contains coordinates
  126.         CALL INTERRUPT &H10 ' call BIOS
  127.  
  128. END SUB
  129.  
  130. SUB CR
  131.     SHARED Attribute%
  132.     ' simulates a carriage return
  133.     ' get cursor position
  134.         REG 1, &H0300
  135.         REG 2, 0
  136.         CALL INTERRUPT &H10
  137.         Row% = REG(4) \ 256
  138.         Col% = (REG(4) AND &HFF)
  139.  
  140.  
  141.         ' establish new cursor position and scroll if necessary
  142.     Col%=0
  143.         INCR Row%
  144.         IF Row%=24 THEN
  145.               Row%=23
  146.                 ' Scroll window up
  147.                 REG 1, &H0601
  148.                 REG 2, Attribute%*256
  149.                 REG 3, 0
  150.                 REG 4, (23 * 256) + 79
  151.                 CALL INTERRUPT &H10
  152.         END IF
  153.  
  154.         ' locate new cursor position
  155.  
  156.         REG 1, &H0200  ' AH contains function 2 = set cursor position
  157.         REG 2, 0       ' BX contains text page 0
  158.         REG 4, (Row% * 256) + Col%  ' DX contains coordinates
  159.         CALL INTERRUPT &H10 ' call BIOS
  160. END SUB
  161.  
  162. SUB BOZOCLS
  163. SHARED Attribute%
  164.     ' scroll function with 0 in AL makes CLS
  165.         REG 1, &H0600
  166.         REG 2, Attribute%*256  ' clear with this attribute
  167.         REG 3, 0
  168.         REG 4, (23 * 256) + 79 ' using 23 protects line 25
  169.                                        ' change to 24 for full screen cls
  170.         CALL INTERRUPT &H10
  171.  
  172.         ' locate new cursor position
  173.         REG 1, &H0200  ' AH contains function 2 = set cursor position
  174.         REG 2, 0       ' BX contains text page 0
  175.         REG 4, 0 ' DX contains coordinates 0,0 (or 1,1)
  176.         CALL INTERRUPT &H10 ' call BIOS
  177. END SUB
  178. $ENDIF
  179.  
  180. $IF %IO.ANSI
  181.  
  182. SUB BOZOCLS
  183. CALL BOZOPRINT(CHR$(27) + "[2J" + CHR$(27) + "[;f")
  184. END SUB
  185.  
  186. SUB BOZOLOCATE (row%, col%)
  187. CALL BOZOPRINT(CHR$(27) + "[" + MID$(STR$(row%), 2) + ";" + MID$(STR$(col%), 2) + "f")
  188. END SUB
  189.  
  190. SUB BOZOCOLOR (fg%, bg%)
  191. CALL BOZOPRINT(CHR$(27) + "[" + MID$(STR$(fg%), 2) + ";" + MID$(STR$(bg%), 2) + "m")
  192. END SUB
  193.  
  194. SUB BOZOPrint(Oput$)
  195.  
  196. For i%=1 to len(Oput$)
  197.     Reg 1,&h200
  198.     Reg 4,asc(Mid$(OPut$,i%,1))
  199.     CALL INTERRUPT &H21
  200. Next i%
  201. END SUB
  202.  
  203.  
  204. FUNCTION BOZOINPUT$
  205.         DO
  206.             C$=BOZOINKEY$
  207.                 IF C$=CHR$(13) THEN EXIT DO
  208.                 IF LEN(C$) THEN BOZOPRINT C$
  209.                 X$=X$+C$
  210.     LOOP
  211.         BOZOPRINT CrLf$
  212.         BOZOINPUT$=X$
  213. END FUNCTION
  214.  
  215.  
  216. FUNCTION BOZOINKEY$
  217.        ' REG 1, &H0600 ' DOS function 6, direct character input no echo
  218.     'REG 4, &HFF
  219.         'CALL INTERRUPT &H21
  220.         'Flags%=REG(0)
  221.         'IF BIT(Flags%,6) THEN BOZOINKEY$=CHR$(REG(1) AND &HFF)
  222.         BOZOINKEY$=INKEY$
  223. END FUNCTION
  224.  
  225. $ENDIF